﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Register.DBUtility;
using Maticsoft.Model.Register;
using System.Data;
using Register.Model;
using Register.IDAL;


/// <summary>
/// FileName: RegisterviewDAL.cs
/// CLRVersion: 4.0.30319.1
/// Author: WBX
/// Corporation: 
/// Description: 
/// DateTime: 2012-7-12 23:06:08
/// </summary>

namespace Register.DAL
{
   public class RegisterviewDAL : IRegisterviewDAL
    {
        private static string tableName = "Register_view";
        public List<Registerview> GetList(string strWhere, int pageIndex, int size)
        {
            DataSet set = DbHelperSQL.getPagedData("*", "Register_AddTime", strWhere, tableName, OrderBy.DESC, pageIndex, size);
            List<Registerview> list = DataSetToList(set);
            return list;
        }
        public int GetListCount(string where)
        {
            int count = 0;
            StringBuilder str = new StringBuilder();
            str.Append(" select count(*) from ");
            str.Append(tableName);
            if (where != null)
            {
                str.Append(" where ");
                str.Append(where);
                count = (int)DbHelperSQL.GetSingle(str.ToString());
            }
            else
            {
                count = (int)DbHelperSQL.GetSingle(str.ToString());
            }
            return count;

        }
        private List<Registerview> DataSetToList(DataSet ds)
        {
            List<Registerview> list = new List<Registerview>();
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                Registerview mi = new Registerview();
                mi.Register_ID = (String)row["Register_ID"];
                mi.Register_AddTime = (DateTime)row["Register_AddTime"];
                mi.PayForRegistrantion_ID = (String)row["PayForRegistrantion_ID"];
                mi.Outpatient_OutpatientType = (String)row["Outpatient_OutpaitentType"];
                mi.Outpatient_ID = (String)row["Outpatient_ID"];
                mi.Hospital_Name = (String)row["Hospital_Name"];
                mi.Hospital_ID = (String)row["Hospital_ID"];
                mi.Register_PatientName = (String)row["Register_PatientName"];
                mi.Departments_Name = (String)row["Departments_Name"]; 
                list.Add(mi);
            }
            return list;
        }



    }
}
